<?php
declare (strict_types = 1);

namespace app\command;

use app\model\HkArea;
use app\model\Store;
use app\tool\GpsUtils;
use app\tool\Http;
use app\tool\ZhConvert;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class Friends extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('friends')
            ->setDescription('the friends command');
    }

    protected function execute(Input $input, Output $output)
    {
	    
	    $rows = Store::select();
	    foreach ($rows as $row){
		    $output->writeln((string)$row->id);
		    if (!empty($row->latitude)&&!empty($row->longitude)){
			    $ids = HkArea::where([['top', '>=', $row->latitude], ['bottom', '<=', $row->latitude], ['left', '<=', $row->longitude], ['right', '>=', $row->longitude]])->column('id');
			    $ids = implode(',', $ids);
			    $row->hk_area_ids = $ids;
			    $row->save();
		    }
	    }
        // 指令输出
        $output->write('success',true);
    }
}
